package com.sip.dbadapter.dao.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
*
*/
@Entity
@Table(name = "REPRESENTATION_MEDIA_TYPE")
public class MediaType implements Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;

	private String mediaName;

	private ScanTypeRest scanTypeRest;

	public MediaType() {
		id = Long.valueOf(0);
	}

	@Id
	@Column(name = "ID", unique = true, nullable = false)
	@GeneratedValue
	public Long getId() {
		return id;
	}

	@Column(name = "MEDIA_NAME", nullable = false)
	public String getMediaName() {
		return mediaName;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "API_ID_REST", nullable = true)
	public ScanTypeRest getScanTypeRest() {
		return scanTypeRest;
	}

	public void setScanTypeRest(ScanTypeRest scanTypeRest) {
		this.scanTypeRest = scanTypeRest;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setMediaName(String mediaName) {
		this.mediaName = mediaName;
	}

	@Override
	public int hashCode() {

		int result = 0;
		result = (int) (31 * result + id);
		result = 31 * result + (mediaName != null ? mediaName.hashCode() : 0);

		return result;
	}

	@Override
	public boolean equals(Object other) {

		if (this == other)
			return true;

		if (other == null || (this.getClass() != other.getClass())) {
			return false;
		}

		MediaType mediaType = (MediaType) other;

		return (this.id == mediaType.id) && (this.mediaName != null && mediaName.equals(mediaType.mediaName));
	}

}
